//
//  AppDelegate.m
//  +LoadDemo
//
//  Created by Jack on 2021/7/27.
//

#import "AppDelegate.h"
#import "JKSon.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    /*
     ----------
     +(void)load:
     0.因为runtime源码中调用load是直接使用load方法的地址，所以category中重写不会覆盖掉类中的重写；
     1.父类load先于子类load;
     2.category的load顺序取决于编译顺序;
     ----------
     
     ----------
     +(void)initialize
     测试结果log
     2021-07-27 17:43:57.958142+0800 +LoadDemo[4399:185333] + init grand
     2021-07-27 17:43:57.958273+0800 +LoadDemo[4399:185333] + init grand
     2021-07-27 17:43:57.958382+0800 +LoadDemo[4399:185333] + init son
     
     原因分析:
     0.runtime中调用initialize的实现((void(*)(Class, SEL))objc_msgSend)(cls, SEL_initialize)，因为使用objc_msgSend,所以category中的重写会覆盖类中的重写；
     1.grand call，被category覆盖；
     2.father call，father中没实现+(void)initialize，所以在父类方法列表中寻找，被category覆盖（可以实现initialize来测试）；
     3.son call，被category覆盖；
     */
    
    JKSon *son = [[JKSon alloc] init];
    [son doNothing];
    
    return YES;
}


#pragma mark - UISceneSession lifecycle


- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}


- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


@end
